asm
  ld sp,$77ff
  end asm

#include "./library/pacmandelay.bas"
#include "./library/smsrnd.bas"

dim eee as uinteger at $7010
dim seed as uinteger at $7012
dim ee0 as uinteger at $7014
dim ee1 as uinteger at $7016
dim ee2 as uinteger at $7018
dim ee3 as uinteger at $701A
dim ex0 as uinteger at $701C
dim ey0 as uinteger at $701E


sub jackrabbitputchar(txp1 as uinteger,typ1 as uinteger,tch1 as ubyte,tat1 as ubyte):
  poke $6000+(txp1 bxor 31)*32+typ1,tch1
  poke $6400+(txp1 bxor 31)*32+typ1,tat1
  end sub

sub jackrabbitputattr(tpo1 as uinteger,tvl1 as ubyte):
  poke $6800+(tpo1 band $3F),tvl1
  end sub

sub jackrabbitputsprite(tly1 as uinteger,txp1 as ubyte,typ1 as ubyte,tch1 as ubyte,tat1 as ubyte):     
  end sub


for ee0=0 to 31
  for ee1=0 to 31
    ee2=seed:seed=smsrnd(seed)
    ee2=seed:seed=smsrnd(seed)
    jackrabbitputchar(ee1,ee0,(seed mod 6)+1,ee2 band %11111100)
    next:next

for ee0=0 to 15
  for ee1=0 to 15
    jackrabbitputchar(ee1+13,ee0+15,ee0*16+ee1,0)
    next:next

eee=0:ex0=8:ey0=8
do
jackrabbitputchar(3,1,48+int(eee/10000) mod 10,0)
jackrabbitputchar(4,1,48+int(eee/1000) mod 10,0)
jackrabbitputchar(5,1,48+int(eee/100) mod 10,0)
jackrabbitputchar(6,1,48+int(eee/10) mod 10,0)
jackrabbitputchar(7,1,48+eee mod 10,0)

ee0=peek($7800) bxor $FF
jackrabbitputchar(5,3,48+int(ee0/100) mod 10,0)
jackrabbitputchar(6,3,48+int(ee0/10) mod 10,0)
jackrabbitputchar(7,3,48+ee0 mod 10,0)

ex0=ex0-((ee0 band 1)/1)+((ee0 band 2)/2)
ey0=ey0-((ee0 band 32)/32)+((ee0 band 64)/64)

ee0=peek($7801) bxor $FF
jackrabbitputchar(5,4,48+int(ee0/100) mod 10,0)
jackrabbitputchar(6,4,48+int(ee0/10) mod 10,0)
jackrabbitputchar(7,4,48+ee0 mod 10,0)

ee0=peek($7802) bxor $FF
jackrabbitputchar(5,5,48+int(ee0/100) mod 10,0)
jackrabbitputchar(6,5,48+int(ee0/10) mod 10,0)
jackrabbitputchar(7,5,48+ee0 mod 10,0)

ee0=peek($7803) bxor $FF
jackrabbitputchar(5,6,48+int(ee0/100) mod 10,0)
jackrabbitputchar(6,6,48+int(ee0/10) mod 10,0)
jackrabbitputchar(7,6,48+ee0 mod 10,0)

jackrabbitputchar(ex0,ey0,eee band 127,0)
eee=eee+1
loop




do:loop

do

for eee=$6000 to $63FF '- videoram-a
  seed=smsrnd(seed)
  poke eee,seed
  pacmandelay(2000)
  poke $7C00,127
  next
for eee=$6400 to $67FF '- videoram-b
  seed=smsrnd(seed)
  poke eee,seed
  pacmandelay(2000)
  poke $7C00,127
  next
for eee=$6800 to $683F '- attr
  seed=smsrnd(seed)
  poke eee,seed
  pacmandelay(2000)
  poke $7C00,127
  next
for eee=$6840 to $685F '-spr1
  seed=smsrnd(seed)
  poke eee,seed
  pacmandelay(2000)
  poke $7C00,127
  next
for eee=$6860 to $687F '-???
  seed=smsrnd(seed)
  poke eee,seed
  pacmandelay(1000)
  poke $7C00,127
  next
for eee=$6880 to $68FF '-spr2
  seed=smsrnd(seed)
  poke eee,seed
  pacmandelay(1000)
  poke $7C00,127
  next
loop

do:loop

'static ADDRESS_MAP_START( main_map, AS_PROGRAM, 8, zaccaria_state )
'AM_RANGE(0x0000, 0x5fff) AM_ROM
'AM_RANGE(0x6000, 0x63ff) AM_READONLY
'AM_RANGE(0x6400, 0x6407) AM_READ(prot1_r)
'AM_RANGE(0x6000, 0x67ff) AM_WRITE(videoram_w) AM_SHARE("videoram") /* 6400-67ff is 4 bits wide */
'AM_RANGE(0x6800, 0x683f) AM_WRITE(attributes_w) AM_SHARE("attributesram")
'AM_RANGE(0x6840, 0x685f) AM_RAM AM_SHARE("spriteram")
'AM_RANGE(0x6881, 0x68c0) AM_RAM AM_SHARE("spriteram2")
'AM_RANGE(0x6c00, 0x6c00) AM_WRITE(flip_screen_x_w)
'AM_RANGE(0x6c01, 0x6c01) AM_WRITE(flip_screen_y_w)
'AM_RANGE(0x6c02, 0x6c02) AM_WRITENOP    /* sound reset */
'AM_RANGE(0x6c06, 0x6c06) AM_WRITE(coin_w)
'AM_RANGE(0x6c07, 0x6c07) AM_WRITE(nmi_mask_w)
'AM_RANGE(0x6c00, 0x6c07) AM_READ(prot2_r)
'AM_RANGE(0x6e00, 0x6e00) AM_READWRITE(dsw_r, sound_command_w)
'AM_RANGE(0x7000, 0x77ff) AM_RAM
'AM_RANGE(0x7800, 0x7803) AM_DEVREADWRITE("ppi8255", i8255_device, read, write)
'AM_RANGE(0x7c00, 0x7c00) AM_READ(watchdog_reset_r)
'AM_RANGE(0x8000, 0xdfff) AM_ROM
'ADDRESS_MAP_END'


do
for eee=$6000 to $6BFF
  seed=smsrnd(seed)
  poke eee,seed
  pacmandelay(1000)
  poke $7C00,127
  next
loop



'
'sub pingpongputsprite(tlayer as ubyte,tx as ubyte,ty as ubyte,tid as ubyte,tclut as ubyte):
'  poke $9006+((tlayer band 15)*4),tx  '- x sprite 0
'  poke $9004+((tlayer band 15)*4),ty bxor 255  '- y sprite 0
'  poke $9005+((tlayer band 15)*4),tid          '- shape sprite 0
'  poke $9003+((tlayer band 15)*4),tclut        '- clut? sprite 0
'  end sub
'
'function test1(t1 as uinteger,t2 as uinteger,t3 as uinteger,t4 as uinteger)  as uinteger
'  end function
'
'sub zpoke(t1 as uinteger,t2 as ubyte)
'  poke t1,t2
'  end sub
'
'sub putchar(tx1 as uinteger, ty1 as uinteger, tch1 as uinteger)
'  poke ($8400+(tx1*32)+ty1) bxor %0000001111100000,(tch1 band 255)
'  end sub
'
'pingpongputsprite(0,21,10,4,3)
'pingpongputsprite(1,21,30,4,3)
'pingpongputsprite(2,21,50,4,3)
'pingpongputsprite(3,21,70,4,3)
'pingpongputsprite(4,21,90,4,3)
'pingpongputsprite(5,21,110,4,3)
'pingpongputsprite(6,21,130,4,3)
'pingpongputsprite(7,21,150,4,3)
'
'seed=0
'
'for ee2=64 to 1023-64
'  for ee3=1 to 100
'    poke $8400+ee2,$01
'    next:next
'
'ee4=0
'for ee2=3 to 3+15
'  for ee3=15 to 15+15
'    poke $8400+ee3+(ee2*32),ee4
'    ee4=ee4+1
'    next:next
'
'ee4=0
'for ee2=20 to 20+7
'  for ee3=15 to 15+15
'    poke $8400+ee3+(ee2*32),ee4 band 3
'    poke $8000+ee3+(ee2*32),int(ee4/4)
'    ee4=ee4+1
'    next:next
'
'
'
'
'for ee2=4 to 7
'  for ee3=2 to 5
'    poke $8400+ee3+(ee2*32),code("X")
'    next
'    next
'
'test1(377,2445,63888,2342)
'
'eee=$4207
'i=code("Q")
'poke eee,i
'eee=eee+1
'i=code("T")
'poke eee,i
'
'seed=0
'for eee=$4400 to $47FF
'  seed=smsrnd(seed)
'  poke eee,seed
'  next
'
'ex0=80:ey0=176
'
'eee=0
'ecsp=0:ecsq=0
'
'
'do
'poke $A600,255 '- watchdog? - it seems to work! thanks, Jim Bagley!!!!
'
'ej0=peek($A800) bxor $ff
'ej1=peek($A880) bxor $ff
'
'poke ($8400+(10*32)+6) bxor %0000001111100000,ej0
'poke ($8400+(10*32)+7) bxor %0000001111100000,ej1
'
'poke ($8400+(12*32)+8) bxor %0000001111100000,48+(ex0 mod 10)
'poke ($8400+(12*32)+7) bxor %0000001111100000,48+((int(ex0/10)) mod 10)
'poke ($8400+(12*32)+6) bxor %0000001111100000,48+((int(ex0/100)) mod 10)
'
'poke ($8400+(13*32)+8) bxor %0000001111100000,48+(ey0 mod 10)
'poke ($8400+(13*32)+7) bxor %0000001111100000,48+((int(ey0/10)) mod 10)
'poke ($8400+(13*32)+6) bxor %0000001111100000,48+((int(ey0/100)) mod 10)
'
'poke ($8400+(14*32)+8) bxor %0000001111100000,48+(eee mod 10)
'poke ($8400+(14*32)+7) bxor %0000001111100000,48+((int(eee/10)) mod 10)
'poke ($8400+(14*32)+6) bxor %0000001111100000,48+((int(eee/100)) mod 10)
'poke ($8400+(14*32)+5) bxor %0000001111100000,48+((int(eee/1000)) mod 10)
'poke ($8400+(14*32)+4) bxor %0000001111100000,48+((int(eee/10000)) mod 10)
'
'poke ($8400+(15*32)+8) bxor %0000001111100000,48+(ej0 mod 10)
'poke ($8400+(15*32)+7) bxor %0000001111100000,48+((int(ej0/10)) mod 10)
'poke ($8400+(15*32)+6) bxor %0000001111100000,48+((int(ej0/100)) mod 10)
'
'poke ($8400+(16*32)+8) bxor %0000001111100000,48+(ej1 mod 10)
'poke ($8400+(16*32)+7) bxor %0000001111100000,48+((int(ej1/10)) mod 10)
'poke ($8400+(16*32)+6) bxor %0000001111100000,48+((int(ej1/100)) mod 10)
'
'poke ($8400+(17*32)+8) bxor %0000001111100000,48+(ecsp mod 10)
'
'if (ej1 band 64)<>0 then: ex0=ex0+1:end if
'if (ej1 band 32)<>0 then: ex0=ex0-1:end if
'if (ej1 band 4)<>0 then: ey0=ey0+1:end if
'if (ej1 band 2)<>0 then: ey0=ey0-1:end if
'
'if (ej1 band 15)<>0 then: ecsq=ecsq+1:end if
'ecsp=(int(ecsq/4))mod 8
'
'ee3=int(eee/4)
'
'pingpongputsprite( 0,ex0   ,ey0   ,4,3)  '- layer,x,y,id,clut
'pingpongputsprite( 1,ex0+16,ey0   ,4,3)  '- layer,x,y,id,clut
'pingpongputsprite( 2,ex0+32,ey0   ,4,3)  '- layer,x,y,id,clut
'pingpongputsprite( 3,ex0+48,ey0   ,4,3)  '- layer,x,y,id,clut
'pingpongputsprite( 4,ex0   ,ey0+16,4,3)  '- layer,x,y,id,clut
'pingpongputsprite( 5,ex0+16,ey0+16,4,3)  '- layer,x,y,id,clut
'pingpongputsprite( 6,ex0+32,ey0+16,4,3)  '- layer,x,y,id,clut
'pingpongputsprite( 7,ex0+48,ey0+16,4,3)  '- layer,x,y,id,clut
'pingpongputsprite( 8,ex0   ,ey0+32,4,3)  '- layer,x,y,id,clut
'pingpongputsprite( 9,ex0+16,ey0+32,4,3)  '- layer,x,y,id,clut
'pingpongputsprite(10,ex0+32,ey0+32,4,3)  '- layer,x,y,id,clut
'pingpongputsprite(11,ex0+48,ey0+32,4,3)  '- layer,x,y,id,clut
'pingpongputsprite(12,ex0   ,ey0+48,4,3)  '- layer,x,y,id,clut
'pingpongputsprite(13,ex0+16,ey0+48,4,3)  '- layer,x,y,id,clut
'pingpongputsprite(14,ex0+32,ey0+48,4,3)  '- layer,x,y,id,clut
'pingpongputsprite(15,ex0+48,ey0+48,4,3)  '- layer,x,y,id,clut
'
'
'eee=eee+1
'loop
'
''-------------------------------------------------------------------------------
'
'text01:
'asm
'  defb "HELLO WORLD!!!!!"
'  end asm
'
''-------------------------------------------------------------------------------
'
'
